package massim.jason.acao;

public enum Direction {

	NORTH("north"),
	SOUTH("south"),
	NORTHWEST("northwest"),
	SOUTHWEST("southwest"),
	NORTHEAST("northeast"),
	SOUTHEAST("southeast"),
	WEST("west"),
	EAST("east"),
	SKIP("skip");
	
	private String value;
	
	Direction(String value) {
		this.setValue(value);
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
	
	public static Direction getDirection(double x1, double y1, double x2, double y2) {
		int vertical = Double.compare(y1, y2);
		int horizontal = Double.compare(x1, x2);
		String directionString = "";
		if(vertical < 0) {
			directionString += "NORTH";
		} else if(vertical > 0) {
			directionString += "SOUTH";
		}
		if(horizontal < 0) {
			directionString += "EAST";
		} else if(horizontal > 0) {
			directionString += "WEST";
		}
		if(directionString.isEmpty()) {
			return Direction.SKIP;
		}
		return Direction.valueOf(directionString);
	}
	
	@Override
	public String toString() {
		return this.value;
	}
}
